﻿using System;
using System.Collections.Generic;
using System.Text;
using RoverStudio.Common.WorldModel;

namespace RoverStudio.Common.Controller
{
    public delegate void ControlSignalChangedHandler(object sender, ControlSignalEventArgs csea);

    public class ControlSignalEventArgs : EventArgs
    {
        private double alpha;

        public double Alpha
        {
            get { return alpha; }

        }
        private double distance;

        public double Distance
        {
            get { return distance; }

        }

        private double vLeft;

        public double VLeft
        {
            get { return vLeft; }

        }
        private double vRight;

        public double VRight
        {
            get { return vRight; }

        }

        private double time;

        public double Time
        {
            get { return time; }
        }
        public ControlSignalEventArgs(double alpha, double distance, double vLeft, double vRight, double time)
        {
            this.alpha = alpha;
            this.distance = distance;
            this.vLeft = vLeft;
            this.vRight = vRight;
            this.time = time;
        }
    }

    public abstract class HighLevelController
    {
        protected bool isActive;

        public bool IsActive
        {
            get
            {
                return this.isActive;
            }
            set
            {
                this.isActive = value;
            }
        }

        protected Path pathToFollow;
        public event ControlSignalChangedHandler ControlSignalChanged;

        public abstract void StartPathFollowing(Path path);
        public abstract void StopPathFollowing();
        public abstract void PausePathFollowing();
        public abstract void ResumePathFollowing();
        public abstract void StepPathFollowing();

        protected void FireControlChangedEvent(double alpha, double distance, double vLeft, double vRight, double time)
        {
            if (ControlSignalChanged != null)
                ControlSignalChanged(this, new ControlSignalEventArgs(alpha, distance, vLeft, vRight, time));

        }
    }
}
